﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Negocio
{
    public class Disease : PersistentObject, IDataErrorInfo
    {
        private string affectedSystem;
        private string name;
        private string description;
        private int severityPoints;
        private string comment;
        private Boolean ofBirth;
        private DateTime date;
        private string status;

        public Disease()
        {
            this.AffectedSystem = "";
            this.Name = "";
            this.Description = "";
            this.SeverityPoints = 0;
            this.Comment = "";
            this.OfBirth = true;
            this.Date = new DateTime();
            status = "";
        }

        public string AffectedSystem 
        {
            get { return this.affectedSystem;}
            set { this.affectedSystem = value;}
        }

        public string Name 
        {
            get { return this.name;}
            set { this.name = value;}
        }

        public string Description 
        {
            get { return this.description;}
            set { this.description = value;}
        }

        public int SeverityPoints 
        {
            get { return this.severityPoints;}
            set { this.severityPoints = value;}
        }

        public string Comment 
        {
            get { return this.comment;}
            set { this.comment = value;}
        }

        public Boolean OfBirth 
        {
            get { return this.ofBirth;}
            set { this.ofBirth = value;}
        }

        public DateTime Date 
        {
            get { return this.date;}
            set { this.date = value;}
        }
        public string ShortDate
        {
            get { return this.date.ToShortDateString(); }
        }
        public string Status 
        {
            get { return status; }
            set { status = value; }
        }

        public override bool Equals(object obj)
        {
            return this.Name.Equals(((Disease)obj).Name) && this.Date.Equals(((Disease)obj).Date);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        public string Error
        {
            get
            {
                return null;
            }
        }
        public string this[string name]
        {
            get
            {
                string result = null;
                if (name == "Name")
                {
                    if (this.name == "")
                    {
                        result = "No se ha ingresado el nombre de la Enfermedad.";
                    }
                }
                if(name=="Description")
                {

                    if (this.description== "")
                    {
                        result = "No se ha ingresado la descripción de la enfermedad.";
                    }
                }
                if (name == "SeverityPoints")
                {

                    if (this.severityPoints<0 && this.severityPoints>10)
                    {
                        result = "La severidad de la Enfermedad no esta en el rango entre 1 y 10.";
                    }
                }
                return result;
            }
        }
    }
}
